#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	double price = 0;
	int m = 0;
	int d = 0;
	int discount = 0;
	scanf("%lf %d %d %d", &price, &m, &d, &discount);
	if (m == 11 && d == 11)
	{
		if (discount == 1) 
		{
			price *= 0.7;
			price -= 50;
		}
		else
			price *= 0.7;
	}
	else
	{
		if (discount == 1)
		{
			price *= 0.8;
			price -= 50;
		}
		else
			price *= 0.8;
	}
	if (price < 0)
	{
		price = 0;
	}
		printf("%.2lf\n", price);
	return 0;
}